package com.kelvin.paopao.utils;

import android.content.Context;
import android.text.TextUtils;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by MCK on 2017/3/16.
 */

public class MessageUtil {
    /**
     * 获取通知消息的实体bean
     *
     * @return
     */
    public static void dealMessageBean(String json, Context context) {
        try {
            String id=null;
            String oid=null;
            JSONObject jo = new JSONObject(json);

            String type = jo.getString("type");

            if(type.equals("约会报名")){
                id=null;
                oid = jo.getString("oId");
            }else{
                id = jo.getString("oId");
                oid=null;
            }

            String content = jo.getString("content");
            int idInt=0;
            if(oid!=null){
                idInt=Integer.parseInt(oid);
            }
            NotificationUtil.notifyNotice(context, type,idInt, content, id);

        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}
